import Taro from '@tarojs/taro'
import storage from "./storage";

export default function request({ url, data = {}, method = 'POST', header = {}, noNeedToken=false }) {
    let d = data;
    if (!(d instanceof Array)) {
        d = {
            ...data
        }
    }

    return Taro.request({
      url,
      data: d,
      method,
      header: {
        ...header,
        cookie:storage.getStorage(),
      }
    })
}

export function requestParam({ url, data = {}, method = 'POST', header = {}, noNeedToken=false }) {
    let d = data;
    return Taro.request({
        url,
        data: d,
        method,
        header: {
            ...header,
            cookie:storage.getStorage(),
        }
    })
}
